import { DataTypes, Model } from 'sequelize'
import sequelize from './db'

export interface IKnowledgeBase {
    id: number
    title: string
    collectionName: string
    description: string
    publishTime: string
}

class KnowledgeBase extends Model {
    declare id: number
    declare title: string
    declare collectionName: string
    declare description: string
    declare publishTime: string
    declare embedModelId: number
    declare embedModel: any
}

KnowledgeBase.init(
    {
        id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        title: {
            type: DataTypes.STRING,
            comment: '名称',
        },
        embedModelId: {
            type: DataTypes.INTEGER,
            comment: '向量化模型id',
        },
        collectionName: {
            type: DataTypes.STRING,
            comment: '向量数据库collectionName',
        },
        description: {
            type: DataTypes.STRING,
            comment: '简介',
        },
        publishTime: {
            type: DataTypes.DATE,
            comment: '发布时间',
        },
    },
    {
        // 这是其他模型参数
        sequelize, // 我们需要传递连接实例
        modelName: 'knowledgebase', // 我们需要选择模型名称
        paranoid: true,
    }
)

export default KnowledgeBase
